<template>
	<view class="content">
		<view class="title">评价星级</view>
		<uni-rate v-if="isTrue" :readonly="true" :size="30" :value="apply_star_num"></uni-rate>
		<view class="title">评价内容</view>
		<view class="cont">{{apply_text}}</view>
	</view>
</template>

<script>
	import uniRate from "@/components/uni-rate/uni-rate.vue"
	export default{
		components:{
			uniRate
		},
		data() {
			return {
				tid: '',
				apply_star_num: 1,
				apply_text: '',
				isTrue: false,
				order_id: ''
			}
		},
		onLoad(e) {
			this.tid = e.tid;
			this.order_id = e.order_id;
			if(this.tid) {
				this.getMyRating();
			} else if(this.order_id) {
				this.getRating();
			}
		},
		methods:{
			getMyRating(){
				this.$zapi.apiPost('user/resources.lists/GetResApplyByApplyidDetail',{tid:this.tid}).then(res=>{
					if(res.data.code == 200) {
						var data = res.data.data;
						this.apply_star_num = data.apply_star_num;
						this.apply_text = data.apply_text;
						this.isTrue = true;
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			getRating() {
				this.$zbapi.apiPost('parent/order/comment/info/'+this.order_id,{user_id:uni.getStorageSync('currentChild').student_id}).then(res=>{
					if(res.data.code == 0 && res.data.data) {
						var data = res.data.data;
						this.apply_star_num = data.score;
						this.apply_text = data.comment;
						this.isTrue = true;
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style>
	.content{
		padding: 40upx;
	}
	.title{
		color: #999999;
		font-size: 34upx;
		line-height: 1;
		margin-bottom: 30upx;
	}
	.uni-rate{
		margin-bottom: 50upx;
	}
	.cont{
		color: #333333;
		font-size: 34upx;
	}
</style>
